package com.zyr.controller;

import com.zyr.domain.Order;
import com.zyr.domain.User;
import com.zyr.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author 张雨润
 * @date 2024/7/28 下午7:07
 * @Description
 */
@RestController
@RequestMapping("/users")
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping("/list")
    @PreAuthorize("hasAuthority('user:page')")
    public Map<String,List<Order>> getListAndOrder() {
        return userService.listAndOrder();
    }
    @PostMapping("/add")
    public boolean add(User user) {
        return userService.saveit(user);
    }
}
